package com.kingschan.util.lang;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
 * PropertiesUtil
 * @author kingschan
 *date:2013-6-7
 */
public class PropertiesUtil {

	public static Properties getProperties(File f)throws Exception{
		InputStream stream=new FileInputStream(f);
		 Properties properties=new Properties();
         properties.load(stream);
        return properties;
	}
	/**
	 * convert Properties to map 
	 * @param p
	 * @return
	 */
	public static Map<String, String> getPropterties(Properties p){
		 Map<String, String> map = new HashMap<String, String>();
		 Set<?> keyValue = p.keySet();
		  Iterator<?> it = keyValue.iterator();
		  while (it.hasNext()) {
			 String key = (String) it.next();
			 map.put(key, p.getProperty(key));
			}
		return map;
		
	}
}
